package com.achcorp.sarch.core.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.achcorp.sarch.core.domain.Document;
import com.achcorp.sarch.core.domain.Tag;

public class TagDAOImp implements TagDAO {
	private HibernateTemplate hibernateTemplate;
	private SessionFactory sessionFactory;

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public List<Tag> getAllTags() {
		List<Tag> l = null;
		Session session = null;
		try {

			session = sessionFactory.openSession();
			l = session.createQuery("from Tag").list();
			session.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return l;
	}

	public Tag getTag(long id) {
		Tag c = hibernateTemplate.get(Tag.class, id);
		return c;
	}

	public void addTag(Tag tag) {
		// TODO Auto-generated method stub

	}

	public void updateTag(Tag tag) {
		// TODO Auto-generated method stub

	}

	public List<Document> getAllDoc(Tag tag, boolean includSub) {
		// TODO Auto-generated method stub
		return null;
	}

}
